/******************************************************************************
 * Copyright 2017-2018 Baidu Robotic Vision Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#ifndef XP_INCLUDE_XP_WORKER_ACTUATOR_H_
#define XP_INCLUDE_XP_WORKER_ACTUATOR_H_

#include <XP/app_api/pose_packet.h>  // for GuideMessageCallback and GuideMessage

namespace XP {

// This is an abstract class of an actuator that converts the physics motion control
// into robot-platform specific control signals
class Actuator {
 public:
  Actuator() {}
  virtual ~Actuator() {}

  virtual bool init();
  virtual bool control(const XP_TRACKER::GuideMessage& guide_message) = 0;
  virtual bool allowMoving(const bool allow_moving);
  virtual bool isInit() const { return is_init_; }
  virtual bool getUltrasoundObstacle() { return false; }
  virtual bool stopActProcess();

 protected:
  bool is_init_ = false;
};

// This actuator sends out control signals via UDP or serial port
class SampleActuator : public Actuator {
 public:
  explicit SampleActuator(const XP_TRACKER::GuideMessageCallback& callback);
  bool control(const XP_TRACKER::GuideMessage& guide_message);
 protected:
  const XP_TRACKER::GuideMessageCallback callback_;
};

}  // namespace XP

#endif  // XP_INCLUDE_XP_WORKER_ACTUATOR_H_
